#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Datetime: 2022/9/26 11:33
# @Author  : CHENWang
# @Site    :
# @File    : weekly_get_blockchair_data.py
# @Software: PyCharm

"""
脚本说明:
"""
from TQR_Applications.factor_database.crypto.onchain_data_update import get_valuation_percentile
from logger import logger
import os
import traceback
from task_monitor import task_to_db, send_error_to_email


if __name__ == '__main__':
    # 下载全量历史数据
    logger.info("开始get_valuation_percentile, asset=BTC")
    task_to_db(os.path.basename(__file__), 'get_valuation_percentile', 0, 'BTC')
    try:
        get_valuation_percentile(asset='BTC', start_date='2014-01-01', end_date=None)
    except Exception as e:
        msg = traceback.format_exc()
        logger.info(msg)
        send_error_to_email(script_name=os.path.basename(__file__), func_name="get_valuation_percentile", message=msg)
        raise e
    task_to_db(os.path.basename(__file__), 'get_valuation_percentile', 1, 'BTC')
    logger.info("成功get_valuation_percentile, asset=BTC")